package com.ljfiction.book.MyView;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;

public class BiaoqianBeijing extends View {

    private Canvas canvas;
    private Path path;
    private Paint p;
    private RectF rectF;
    public  String stringColor="#f77583";
    private float width,hight,lintop,paintsize;
    public BiaoqianBeijing(Context context) {
        super(context);
    }

    public BiaoqianBeijing(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public BiaoqianBeijing(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }
public void setBackcolor(String colorString){
        stringColor=colorString;

}
    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        width=getMeasuredWidth();
        hight=getMeasuredHeight();
        lintop=hight/7;
        paintsize=width/50;
        path=new Path();
        p=new Paint(Paint.ANTI_ALIAS_FLAG);
        p.setAntiAlias(true);
        rectF=new RectF(paintsize/2,lintop,hight-lintop,hight-paintsize/2);
        p.setColor(Color.parseColor(stringColor));
        p.setStyle(Paint.Style.STROKE);
        p.setStrokeWidth(paintsize);
       /* path.moveTo(100,100);
        path.quadTo(300,100,400,200);
        path.quadTo(300,300,400,400);
        path.quadTo(300,500,200,400);
        path.quadTo(100,300,200,200);
        path.close();*/

        //canvas.drawOval(rectF, p);
        canvas.drawArc(rectF,90,180,false,p);
        rectF.set(width-hight+lintop,lintop,width-paintsize/2,hight-paintsize/2);
        canvas.drawArc(rectF,270,180,false,p);
        /*rectF.set(176,3,200,40);
        canvas.drawArc(rectF,100,100,false,p);*/
        canvas.drawLine((hight-lintop-paintsize/2)/2,hight-paintsize/2,width-(hight-lintop-paintsize/2)/2,hight-paintsize/2,p);
        canvas.drawLine(width*7/24,0,width*3/8,hight*9/35,p);
        canvas.drawLine(width*5/12,lintop,width-(hight-lintop-paintsize/2)/2-paintsize/2,lintop,p);

        path.moveTo(width*7/24,hight/7+3);
        path.quadTo(width*7/24,hight/7,width*3/8,hight*9/35);
        path.close();
        canvas.drawPath(path,p);
        p.setStyle(Paint.Style.FILL);
        canvas.drawPoint((hight-lintop-paintsize/2)/2+paintsize*2,lintop,p);


    }
}
